const path = require('path')
const webpack = require('webpack')

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    configureWebpack: {

        plugins: [

            new webpack.ProvidePlugin({

                $: "jquery",

                jQuery: "jquery",

                "windows.jQuery": "jquery"

            })

        ]

    },
    publicPath: process.env.NODE_ENV === 'production'
        ? '/frontend/'
        : '/',
    productionSourceMap: false,
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('@views', resolve('src/views'))
            .set('@util', resolve('src/util'))
            .set('@config', resolve('src/config'))
            .set('@assets', resolve('src/assets'))
            .set('@api', resolve('src/api'))
            .set('@directive', resolve('src/directive'))
            .set('@components', resolve('src/components'))

    },
    devServer: {
        disableHostCheck: true,
        proxy: {
            '/api': {
                target: 'http://49.234.181.104:8086/',
                changeOrigin: true,
                ws: true,
                pathRedirects: {}
            },
            '/ihubApi': {
                target: 'http://hybriduat.sanofidigital.cn/snfihub',
                changeOrigin: true,
                ws: true,
                pathRedirects: {}
            },
            '/documentApi': {
                target: 'http://hybriduat.sanofidigital.cn/snfihub',
                changeOrigin: true,
                ws: true,
                pathRedirects: {}
            },
            '/DBUToolPGSQL': {
                target: 'http://sit.kelefan.cn',
                changeOrigin: true,
                ws: true,
                pathRedirects: {}
            }
        }
    }
}
